﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ArchivesManagementBL;

public partial class ViewActivityAwardInformation : System.Web.UI.Page
{
    ActivityAwardInformationBL activityAwardInformationBL = new ActivityAwardInformationBL();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindActivityAwardInformation();
        }
    }

    protected void BindActivityAwardInformation()
    {
        this.GridView1.DataSource = activityAwardInformationBL.GetActivityAwardInformation();
        this.GridView1.DataBind();
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "this.style.backgroundcolor = currentcolor");
            ImageButton imgbtn = (ImageButton)e.Row.FindControl("imgbtnDelete");
            imgbtn.Attributes.Add("onclick", "return confirm('确认删除吗？');");
        }
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string cmd = e.CommandName;
        int id = Convert.ToInt32(e.CommandArgument);
        if (cmd == "De")
        {
            activityAwardInformationBL.DeleteActivityAwardInformationByStudentId(id);
        }
        else if (cmd == "Ed")
        {
            Page.Server.Transfer("EditActivityAwardInformation.aspx? ID=" + id.ToString());
        }
        BindActivityAwardInformation();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {

    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        BindActivityAwardInformation();
    }
}